/**
 * 
 */
package edu.gtcfla.km.security;

import java.security.MessageDigest;

/**
 * @author Bill Vison
 *
 */
public final class MD5Encrypt {

	public static final String encrypt(String inString) {
	    try {
	        MessageDigest md;
	        //MD5, SHA, SHA-1
	        md = MessageDigest.getInstance("MD5");
	        byte[] output = md.digest(inString.getBytes());
	        StringBuffer sb = new StringBuffer(2 * output.length);
	        for (int i = 0; i < output.length; ++i) {
	          int k = output[i] & 0xFF;
	          if (k < 0x10) {
	            sb.append('0');
	          }
	          sb.append(Integer.toHexString(k));
	        }
	        return sb.toString();
	      } catch (java.security.NoSuchAlgorithmException e) {
	      }
	    return null;
	}	
	
}
